﻿using System;
using System.Drawing;
using pub.CmdUI.Cmd;
using pub.CmdUI.UI.Control;
using pub.NET20Fix;

namespace todo.Ribbon.CmdUI
{
    public class RibbonToggleButtonUI : IControlUI
    {
        private RibbonToggleButton _button;
        private Action _triggerCallback;

        public RibbonToggleButtonUI(RibbonToggleButton button)
        {
            _button = button;
            _button.OnClick += _button_OnClick;
        }

        private void _button_OnClick(object sender, EventArgs e)
        {
            if (_triggerCallback != null)
            {
                _triggerCallback();
            }
        }

        public Action TriggerCallback
        {
            set { _triggerCallback = value; }
        }

        public Bitmap Icon
        {
            set
            {
                //
            }
        }

        public string Label
        {
            set
            {
                //
            }
        }

        public string Tooltip
        {
            set
            {
                //
            }
        }

        public void Update(ICmd cmd)
        {
            _button.Enabled = cmd.State.Enabled;
            _button.Checked = cmd.State.Checked ?? false;
        }
    }
}